/* EasyWay Game Engine
 * Copyright (C) 2007 Daniele Paggi.
 *  
 * Written by: 2007 Daniele Paggi<dshnt@hotmail.com>
 *   
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
package org.easyway.editor.forms.components.extended;

import java.util.ArrayList;

import org.easyway.editor.commands.user.GetPoint;
import org.easyway.editor.forms.components.Button;
import org.easyway.editor.forms.components.InputText;

public class GetPointButton extends Button {

	private static final long serialVersionUID = 8278391110821234487L;

	public static ArrayList<GetPointButton> list = new ArrayList<GetPointButton>(
			10);

	public static GetPointButton findById(int id) {
		for (GetPointButton pb : list) {
			if (pb.id == id) {
				return pb;
			}
		}
		return null;
	}

	int id;

	public GetPointButton(int id) {
		super("getPoint","select");
		this.id = id;
		list.add(this);
	}

	InputText inputx;

	InputText inputy;

	@Override
	public void command() {
		float xy[] = GetPoint.getPoint();
		if (inputx != null) {
			inputx.setValue("" + xy[2]);
		}
		if (inputy != null) {
			inputy.setValue("" + xy[3]);
		}
	}

}
